<style scoped lang="less">
.header-info {
    display: flex;
    align-items: center;
    .operation {
        display: inline-flex;
        .icon-item {
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 40px;
            height: 35px;
            margin-right: 10px;
            cursor: pointer;
            .dot{
                position: absolute;
                top: 5px;
                right: 5px;
                width: 5px;
                height: 5px;
                border-radius: 50%;
                background-color: red;
            }
            &:hover {
                background-color: #f5f5f5;
            }
        }
        
    }
    .info{
            .user-info{
                display: flex;
                align-items: center;
                cursor: pointer;
                .avatar{
                    width: 40px;
                    height: 40px;
                    border-radius: 50%;
                    margin-right: 10px;
                }
                .name{
                    font-size: 16px;
                }
            }
        }
}

.el-tooltip__trigger:focus-visible{
    outline: unset;
}
</style>

<template>
    <div class="header-info">
        <div class="operation">
            <div class="icon-item">
                <span class="dot"></span>
                <el-icon size="20px">
                    <Message />
                </el-icon>
            </div>
            <div class="icon-item">
                <span class="dot"></span>
                <el-icon size="20px">
                    <ChatDotRound />
                </el-icon>
            </div>
            <div class="icon-item">
                <el-icon size="20px">
                    <Search />
                </el-icon>
            </div>
        </div>
        <div class="info">
            <el-dropdown>
                <div class="user-info">
                    <img class="avatar" src="../../../assets/img/myimage.png" alt="">
                    <span class="name">admin123</span>
                </div>
                <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item @click="handleLogout">
                            <el-icon>
                                <CircleClose/>
                            </el-icon>
                            <span>
                                退出登录
                            </span>
                        </el-dropdown-item>
                        <el-dropdown-item divided>
                            <el-icon>
                                <InfoFilled/>
                            </el-icon>
                            <span>
                                个人信息
                            </span>
                        </el-dropdown-item>
                        <el-dropdown-item>
                            <el-icon>
                                <Unlock/>
                            </el-icon>
                            <span>
                                修改密码
                            </span>
                        </el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>
        </div>
    </div>
</template>

<script setup>
import { CircleClose, InfoFilled, Unlock } from '@element-plus/icons-vue';
import { ref } from 'vue';
import { localCache } from '@/utils/cache';
import { useRouter } from 'vue-router';
const router = useRouter();


// 退出登录
function handleLogout() {
    console.log('退出登录');
    localCache.removeCache('token');
    router.push('/login');
}
</script>